import launch
from launch import LaunchDescription
from launch_ros.actions import Node
from launch_ros.actions import ComposableNodeContainer
from launch_ros.descriptions import ComposableNode
from ament_index_python.packages import get_package_share_directory
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.actions import IncludeLaunchDescription
from launch.substitutions import Command

import os

def generate_launch_description():
    ld = LaunchDescription()
    # pose_solver_package_dir = get_package_share_directory('pose_solver')
    # control_package_dir = get_package_share_directory('control')

    # camera_namespace = 'camera'
    # params_file = os.path.join(get_package_share_directory('ros_usbcapture'),'config','RosUsbCapture.yaml')
    detector_params = os.path.join(
      get_package_share_directory('deepdetector'),'config','detector_params.yaml')
    container = ComposableNodeContainer(
            name='my_container',
            namespace='',
            package='rclcpp_components',
            executable='component_container',
            
            composable_node_descriptions=[
                ComposableNode(
                    package='deepdetector',
                    # namespace=camera_namespace,
                    plugin='wmj::DeepDetector_Node',
                    name='deepdetector_right',
                    remappings=
                    [
                        ('Armors' , "/Armors"),
                        ('image_raw', '/camera/right_image_raw')
                    ],
                    parameters=[detector_params],
                    extra_arguments=[{'use_intra_process_comms': True}],
                    ),
            ],
            output='screen',
    )
    ld.add_action(container)
    return ld
